package ch.fusun.baron.basic.client.ui;

import java.util.List;

import ch.fusun.baron.basic.command.AnnectLandCommand;
import ch.fusun.baron.basic.command.util.PlayerUtil;
import ch.fusun.baron.client.rmi.ClientService;
import ch.fusun.baron.client.ui.messages.Messages;
import ch.fusun.baron.core.injection.Inject;
import ch.fusun.baron.map.Tile;
import ch.fusun.baron.player.api.Country;

/**
 * Annects land
 */
public class AnnectLandTileAction extends AbstractTileAction {

	@Inject
	private ClientService clientService;
	@Inject
	private PlayerUtil playerUtil;

	/**
	 * Injection constructor
	 */
	public AnnectLandTileAction() {
	}

	@Override
	public void execute(Object tile) {
		List<Country> countriesForUser = playerUtil.getCountriesForUser();
		if (countriesForUser.size() > 0) {
			clientService.execute(new AnnectLandCommand(
					playerUtil.getDynasty(), countriesForUser.get(0),
					(Tile) tile));
		}
	}

	@Override
	public String getText() {
		return Messages.AnnectLandTileAction_Description;
	}

	@Override
	public Class<?> getReactionClass() {
		return Tile.class;
	}

}
